
package generic.gui.util;

import java.awt.GridLayout;
import java.util.ArrayList;

import javax.swing.JComboBox;

@SuppressWarnings("serial")
public class JComboxBoxLabelHorizontalForm <ENTITY> extends JPanelForm {

		private JLabelForm label;
		private JComboBox<?> combo;
		
		@SuppressWarnings({ "unchecked", "rawtypes" })
		public JComboxBoxLabelHorizontalForm(String name, ArrayList<ENTITY> entity) {
			GridLayout bl = new GridLayout(1, 2);
			bl.setHgap(5);
			setLayout(bl);
			
			if (entity != null)
				setCombo(new JComboBox(entity.toArray()));
			
			getLabel().setText(name);
			
			add(getLabel());
			add(getCombo());
		}

		public JLabelForm getLabel() {
			if (label == null) {
				label = new JLabelForm();
				label.setLayout(null);
			}
			return label;
		}

		public void setLabel(JLabelForm label) {
			this.label = label;
		}

		@SuppressWarnings("rawtypes")
		public JComboBox<?> getCombo() {
			if (combo == null) {
				combo = new JComboBox();
				combo.setLayout(null);
			}
			return combo;
		}

		public void setCombo(JComboBox<?> combo) {
			this.combo = combo;
		}
}
